<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>问卷调查管理系统</title>
  <link rel="stylesheet" href="/css/layui.css">
  <link rel="stylesheet" href="/css/bootstrap.min.css">

  <style>
    #test1 {
      width: 100%;
      height: 600px;
    }
  </style>
</head>

<body>
  <div class="layui-layout layui-layout-admin">
    <div class="layui-header">
      <div class="layui-logo layui-hide-xs layui-bg-black">问卷调查管理系统</div>
      <!-- 头部区域（可配合layui 已有的水平导航） -->
      <ul class="layui-nav layui-layout-left">
        <!-- 移动端显示 -->
        <li class="layui-nav-item layui-show-xs-inline-block layui-hide-sm" lay-header-event="menuLeft">
          <i class="layui-icon layui-icon-spread-left"></i>
        </li>

        <li class="layui-nav-item layui-hide-xs"><a href="./create">创建模块</a></li>
        <li class="layui-nav-item layui-hide-xs"><a href="./questioncontrol">问卷管理</a></li>


      </ul>
      <ul class="layui-nav layui-layout-right">
        <li class="layui-nav-item layui-hide layui-show-md-inline-block">
          <a href="javascript:;">
            <img src="/Jpg/8.png" class="layui-nav-img">
            milu
          </a>
          <dl class="layui-nav-child">
            <dd><a href="javascript:;">修改密码</a></dd>
            <dd><a href="/logout">注销</a></dd>
          </dl>
        </li>
        <li class="layui-nav-item" lay-header-event="menuRight" lay-unselect>
          <a href="javascript:;">
            <i class="layui-icon layui-icon-more-vertical"></i>
          </a>
        </li>
      </ul>
    </div>

    <div class="layui-side layui-bg-black">
      <div class="layui-side-scroll">
        <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
        <ul class="layui-nav layui-nav-tree" lay-filter="test">
          <li class="layui-nav-item layui-nav-itemed">
            <a class="" href="javascript:;">menu group 1</a>
            <dl class="layui-nav-child">
              <dd><a href="./homepage">问卷首页</a></dd>
              <dd><a href="./create">创建问卷</a></dd>
              <dd><a href="javascript:;">统计问卷</a></dd>
            </dl>
          </li>
          <li class="layui-nav-item">
            <a href="javascript:;">menu group 2</a>
            <dl class="layui-nav-child">
              <dd><a href="javascript:;">问卷详情</a></dd>
              <dd><a href="./questionserver">样本服务</a></dd>
              <dd><a href="javascript:;">用户个人信息</a></dd>
              <dd><a href="javascript:;">系统日志功能</a></dd>


            </dl>
          </li>



        </ul>
      </div>
    </div>

    <div class="layui-body">



      <!-- 内容主体区域 -->
      <div style="padding: 15px;">
        {% block content %}

        {% endblock %}


      </div>
    </div>

    <div class="layui-footer">
      <div class="div_foot" style="margin-left: 250px;">
        <a style="color:pink">
          2021-2022©Lucas科技有限公司
        </a>

        <a href="https://beian.miit.gov.cn/" style="text-decoration:none; color: pink; margin-left: 30px;">
          赣ICP备2020013193号-1
        </a>

        <a target="_blank" href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=35080202351206"
          style="display:inline-block;text-decoration:none;height:20px;line-height:20px; margin-left: 80px;"><img
            src="/jpg/备案图标.png" style="float:left;" />

          <a href="https://beian.miit.gov.cn/" style="text-decoration:none; color:pink ">
            闽公网安备 35080202351206号
          </a>

      </div>


    </div>
  </div>




  <!-- Modal -->
  <div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <h5 class="modal-title" id="exampleModalLabel">发表评测</h5>
          <button type="button" class="close" data-dismiss="modal" aria-label="Close">
            <span aria-hidden="true">&times;</span>
          </button>
        </div>


        <div class="modal-body">


          <form class="layui-form" id="addquestion">

            <div class="layui-form-item">
              <label class="layui-form-label">主题</label>
              <div class="layui-input-block">
                <input type="text" name="title" id="theme" placeholder="请输入标题" autocomplete="off" class="layui-input">
              </div>
            </div>

            <div class="layui-form-item layui-form-text">
              <label class="layui-form-label">说明</label>
              <div class="layui-input-block">
                <textarea name="desc" id="description" placeholder="请输入内容" class="layui-textarea"></textarea>
              </div>
            </div>


            <label for="inputEmail3" class="col-sm-2 col-form-label">问一:</label>
            <div class="col-sm-10">
              <input type="text" class="form-control" id="q1" name="que1">
            </div>
            <label for="inputEmail3" class="col-sm-2 col-form-label">问二:</label>
            <div class="col-sm-10">
              <input type="text" class="form-control" id="q2" name="que2">
            </div>
            <label for="inputEmail3" class="col-sm-2 col-form-label">问三:</label>
            <div class="col-sm-10">
              <input type="text" class="form-control" id="q3" name="que3">
            </div>
            <label for="inputEmail3" class="col-sm-2 col-form-label">问四:</label>
            <div class="col-sm-10">
              <input type="text" class="form-control" id="q4" name="que4">
            </div>
            <label for="inputEmail3" class="col-sm-2 col-form-label">问五:</label>
            <div class="col-sm-10">
              <input type="text" class="form-control" id="q5" name="que5">
            </div>

          </form>

        </div>

        <div class="modal-footer">
          <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
          <button type="button" class="btn btn-primary" onclick="add()">发表</button>
        </div>

      </div>
    </div>
  </div>


  <script src="/js/jquery-3.6.0.min.js"></script>
  <script src="/js/bootstrap.min.js"></script>
  <script src="/layui.js"></script>



  <script>
    //JS 
    layui.use(['element', 'layer', 'util'], function () {
      var element = layui.element
        , layer = layui.layer
        , util = layui.util
        , $ = layui.$;

      //头部事件
      util.event('lay-header-event', {
        //左侧菜单事件
        menuLeft: function (othis) {
          layer.msg('展开左侧菜单的操作', { icon: 0 });
        }
        , menuRight: function () {
          layer.open({
            type: 1
            , content: '<div style="padding: 15px;">处理右侧面板的操作</div>'
            , area: ['260px', '100%']
            , offset: 'rt' //右上角
            , anim: 5
            , shadeClose: true
          });
        }
      });

    });
    layui.use(['carousel', 'form'], function () {
      var carousel = layui.carousel
        , form = layui.form;

      carousel.render({
        elem: '#test10'
        , width: '778px'
        , height: '440px'
        , interval: 5000
      });


      var $ = layui.$, active = {
        set: function (othis) {
          var THIS = 'layui-bg-normal'
            , key = othis.data('key')
            , options = {};

          othis.css('background-color', '#5FB878').siblings().removeAttr('style');
          options[key] = othis.data('value');
          ins3.reload(options);
        }
      };

      //其它示例
      $('.demoTest .layui-btn').on('click', function () {
        var othis = $(this), type = othis.data('type');
        active[type] ? active[type].call(this, othis) : '';
      });
    });



    //创建问卷
    function add() {
      let theme = $('#theme').val();
      let description = $('#description').val();
      let q1 = $("#q1").val();
      let q2 = $("#q2").val();
      let q3 = $("#q3").val();
      let q4 = $("#q4").val();
      let q5 = $("#q5").val();

      if (q1.length > 0 && q2.length > 0 && q3.length && q4.length && q5.length && theme.length > 0 && description.length > 0) {
        // ajax请求
        $.ajax({
          url: "/createDone",
          type: "POST",
          data: $('#addquestion').serialize(),
          dataType: "json",
          success: function (res) {
            console.log(res);
            if (res.code === 200) {
              let data = JSON.parse(res.data);
              console.log(data);
              window.location.href = "/";

            } else {
              alert(res.msg);
            }

          },
          error: function (msg) {
            alert('网络或者服务器有问题');
          }
        })
      } else {// 验证不通过，提示相关信息，并且阻止提交
        alert('信息不能为空');
        return false;
      }
    }



    //删除问卷  
    function commit(id) {

      console.log(id, 'kan')

      let data = {
        qid: id
      }

      $.ajax({
        url: "/droprow",
        type: "POST",
        dataType: "json",
        data: data,
        success: function (res) {
          console.log(res);
          if (res.code === 200) {
            layer.msg('删除成功', {
              icon: 1,
              time: 2000 //2秒关闭（如果不配置，默认是3秒）
            }, function () {
            });
            window.location.href = "/questioncontrol";
          }
        },
        error: function (msg) {
          console.log('网络或者服务器有问题');
        }
      })
    }


    //详情
    function getdetail(id) {
      console.log(id, 'kan')

      let data = {
        ssid: id
      }

      $.ajax({
        url: "/questiondetail",
        type: "POST",
        dataType: "json",
        data: data,
        success: function (res) {
          console.log(res);
          if (res.code === 200) {
            window.location.href = "/questiondetailed";
          }
        },
        error: function (msg) {
          console.log('网络或者服务器有问题');
        }
      })
    }

    //统计
    function getcount(id) {
      console.log(id, 'kan')

      let data = {
        ccid: id
      }

      $.ajax({
        url: "/questioncount",
        type: "POST",
        dataType: "json",
        data: data,
        success: function (res) {
          console.log(res);
          if (res.code === 200) {
            window.location.href = "/questioncounted";
          }
        },
        error: function (msg) {
          console.log('网络或者服务器有问题');
        }
      })
    }



  </script>
</body>

</html>